program mfort
	use compute
	use adjcvmod
	use taugrid
	implicit none
	integer	:: iNy,i
	integer	:: im,kl,ku
	call rnset(1654)
	
	call inittime
	do im=1,4
		taumodel=.false.
		level=0.05
		select case(im)
			case(1)
				n=194
				kl=1; ku=1
			case(2)
				n=4
				kl=4; ku=100				
			case(3:4)
				n=522
				kl=25; ku=kl
				taumodel=.true.
				level=0.04
		end select
		do k=kl,ku,2
			call setgammas
			if(taumodel) then
				if(im==3) then
					call loadtaudata
				else
					call loadtaudatanorm
				endif
				call settaugrid()
			endif
			do tstind=0,4
				print *,"im",im,"tstind",tstind
				if(taumodel) then
					nxsi=size(taumsxgrid,2)			
				else
					nxsi=merge(18,10,tstind==tstxsi)
				endif	
				call set_tststats
				if(tstind==tstxsi .and. (.not. taumodel)) then
					call savexsicvs
				else
					call findajdcv
				endif
				print *,"XXXXXXXXXXXX k=", k," XXXXXXXXXXXXXXXXXX"
			enddo
		enddo
	enddo
	n=4
	k=30
	nxsi=10
	im=2
	taumodel=.false.
	if(allocated(ys)) deallocate(ys,yks,tau,gammas)
	allocate(gammas(k,n,nsim),ys(k,n),yks(n),tau(n))
	yks=k	
	call Size_Dependence
end program